﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace VetumaForSP2010.Configuration
{
    public class VetumaForSharePointConfig : ConfigurationSection
    {
        [ConfigurationProperty("VetumaConfig", IsRequired = true)]
        public VetumaConfig VetumaConfig
        {
            get
            {
                if (this["VetumaConfig"] != null)
                {
                    return this["VetumaConfig"] as VetumaConfig;
                }
                else
                {
                    throw new NullReferenceException("VetumaConfig section missing from web.config.");
                }
            }
        }

        [ConfigurationProperty("RegistrationConfig", IsRequired = true)]
        public RegistrationConfig RegistrationConfig
        {
            get
            {
                if (this["RegistrationConfig"] != null)
                {
                    return this["RegistrationConfig"] as RegistrationConfig;
                }
                else
                {
                    throw new NullReferenceException("RegistrationConfig section missing from web.config.");
                }
            }
        }

        [ConfigurationProperty("SharePointGroups", IsRequired = true)]
        public SharePointGroups SharePointGroups
        {
            get
            {
                if (this["SharePointGroups"] != null)
                {
                    return this["SharePointGroups"] as SharePointGroups;
                }
                else
                {
                    throw new NullReferenceException("SharePointGroups section missing from web.config.");
                }
            }
        }

        public VetumaForSharePointConfig() { }

        public static VetumaForSharePointConfig getConfig()
        {
            return ConfigurationManager.GetSection("VetumaForSharePointConfig") as VetumaForSharePointConfig;
        }
    }
}
